package com.example.app3;

import android.Manifest;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button rr;
    private Button rrr;
    private Button rr1;
    private Button rr2;
    private Button rr3;
    private Button rr4;
    private Button rr5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        rr = (Button) findViewById(R.id.rr);
        rr.setOnClickListener(this);
        rrr = (Button) findViewById(R.id.rrr);
        rrr.setOnClickListener(this);
        rr1 = (Button) findViewById(R.id.rr1);
        rr1.setOnClickListener(this);
        rr2 = (Button) findViewById(R.id.rr2);
        rr2.setOnClickListener(this);
        rr3 = (Button) findViewById(R.id.rr3);
        rr3.setOnClickListener(this);
        rr4 = (Button) findViewById(R.id.rr4);
        rr4.setOnClickListener(this);
        rr5 = (Button) findViewById(R.id.rr5);
        rr5.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rr:
                //拨号界面
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:"+rr.getText().toString().trim()));
                startActivity(intent);
            case R.id.rrr:
//                //手机信息页面
//                Intent intent1 = new Intent();
//                ComponentName cm = new ComponentName("com.android.settings",
//                        "com.android.settings.RadioInfo");
//                intent1.setComponent(cm);
//                intent1.setAction("android.intent.action.VIEW");
//                startActivity(intent1);
                break;
            case R.id.rr1:
                //设置
                startActivity(new Intent(Settings.ACTION_SETTINGS));
                break;
            case R.id.rr2:
                //网络
                startActivity(new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS));
                break;
            case R.id.rr3:
                //蓝牙
                startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
                break;
            case R.id.rr4:
                //时间
                startActivity(new Intent(Settings.ACTION_DATE_SETTINGS));
                break;
            case R.id.rr5:
                //位置服务
                startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS ));
                break;
        }
    }
}